import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: 路由配置项
 *
 * hidden: true                   // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true               // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect           // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'             // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * meta : {
 noCache: true                // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
 title: 'title'               // 设置该路由在侧边栏和面包屑中展示的名字
 icon: 'svg-name'             // 设置该路由的图标，对应路径src/assets/icons/svg
 breadcrumb: false            // 如果设置为false，则不会在breadcrumb面包屑中显示
 }
 */

// 公共路由
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: (resolve) => require(['@/views/redirect'], resolve)
      }
    ]
  },
  {
    path: '/login',
    component: (resolve) => require(['@/views/login'], resolve),
    hidden: true
  },
  {
    path: '/404',
    component: (resolve) => require(['@/views/error/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: (resolve) => require(['@/views/error/401'], resolve),
    hidden: true
  },
  {
    path: '/app',
    component: (resolve) => require(['@/views/system/appUpdate/index'], resolve),
    hidden: true,
  },
  {
    path: '/dp',
    component: (resolve) => require(['@/views/system/dp/dp'], resolve),
    hidden: true,
  },
  // {
  //   path: '',
  //   component: Layout,
  //   redirect: 'index',
  //   children: [
  //     {
  //       path: 'index',
  //       component: (resolve) => require(['@/views/index'], resolve),
  //       name: '首页',
  //       meta: {title: '首页', icon: 'dashboard', noCache: true, affix: true}
  //     }
  //   ]
  // },
  {
    path: '/',
    component: Layout,
    redirect: '/patrol/home',
    children: [
      {
        path: 'patrol/home',
        component: (resolve) => require(['@/views/patrol/home/index'], resolve),
        name: "首页",
        meta: {title: '首页', icon: 'index', noCache: true, affix: true}
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'profile',
        component: (resolve) => require(['@/views/system/user/profile/index'], resolve),
        name: 'Profile',
        meta: {title: '个人中心', icon: 'user'}
      }
    ]
  },
  {
    path: '/dict',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'type/data/:dictId(\\d+)',
        component: (resolve) => require(['@/views/system/dict/data'], resolve),
        name: 'Data',
        meta: {title: '字典数据', icon: ''}
      }
    ]
  },
  {
    path: '/job',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'log',
        component: (resolve) => require(['@/views/monitor/job/log'], resolve),
        name: 'JobLog',
        meta: {title: '调度日志'}
      }
    ]
  },
  {
    path: '/gen',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'edit/:tableId(\\d+)',
        component: (resolve) => require(['@/views/tool/gen/editTable'], resolve),
        name: 'GenEdit',
        meta: {title: '修改生成配置'}
      }
    ]
  }, {
    path: '/form',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '',
        component: (resolve) => require(['@/views/patrol/form/index'], resolve),
        name: 'form',
        meta: {title: '表单', activeMenu: '/form/index'}
      },
      {
        path: 'add',
        component: (resolve) => require(['@/views/patrol/form/addform'], resolve),
        name: 'addform',
        meta: {title: '新增填表', activeMenu: '/form/index'}
      },
      {
        path: 'viewschool/:id(\\d+)',
        component: (resolve) => require(['@/views/patrol/form/viewschool'], resolve),
        name: 'viewschool',
        meta: {title: '填报学校', activeMenu: '/form', noCache: true}
      },
      {
        path: 'rincianbentuk',
        component: (resolve) => require(['@/views/patrol/form/rincianbentuk'], resolve),
        name: 'rincianbentuk',
        meta: {title: '填报详情', activeMenu: '/form', noCache: true}
      },
      {
        path: 'see/:if',
        component: (resolve) => require(['@/views/patrol/form/see'], resolve),
        name: 'see',
        meta: {title: '表单详情', activeMenu: '/form', noCache: true}
      },
      {
        path: 'template',
        component: (resolve) => require(['@/views/patrol/check/checkType'], resolve),
        name: 'checkType',
        meta: {title: '模板管理'}
      },
      {
        path: 'question',
        component: (resolve) => require(['@/views/patrol/check/question'], resolve),
        name: 'question',
        meta: {title: '问题编辑'}
      },
      {
        path: 'answer',
        component: (resolve) => require(['@/views/patrol/check/answer'], resolve),
        name: 'answer',
        meta: {title: '检查详情'}
      },
      {
        path: 'addCheck',
        component: (resolve) => require(['@/views/patrol/check/addCheck'], resolve),
        name: 'addCheck',
        meta: {title: '新增检查'}
      },
      {
        path: 'viewCheck',
        component: (resolve) => require(['@/views/patrol/check/viewCheck'], resolve),
        name: 'viewCheck',
        meta: {title: '检查查看'}
      }
    ]
  }, {
    path: '/notification',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '',
        component: (resolve) => require(['@/views/patrol/notify'], resolve),
        name: 'Notification',
        meta: {title: '通知公告'}
      },
      {
        path: 'add',
        component: (resolve) => require(['@/views/patrol/notify/addNotify'], resolve),
        name: 'AddNotify',
        meta: {title: '新增通知'}
      }, {
        path: 'detail',
        component: (resolve) => require(['@/views/patrol/notify/notifyDetail'], resolve),
        name: 'NotifyDetail',
        meta: {title: '通知详情'}
      }, {
        path: 'detail/answer',
        component: (resolve) => require(['@/views/patrol/notify/notifyAnswerDetail'], resolve),
        name: 'NotifyAnswerDetail',
        meta: {title: '回复详情'}
      }
    ]
  }, {
    path: '/schoolNotify',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '',
        component: (resolve) => require(['@/views/patrol/notify/schoolNotify'], resolve),
        name: 'SchoolNotify',
        meta: {title: '通知公告'}
      },
      {
        path: 'school/detail',
        component: (resolve) => require(['@/views/patrol/notify/schoolNotify/notifyDetail'], resolve),
        name: 'SchoolNotifyDetail',
        meta: {title: '通知详情'}
      }
    ]
  },
  {
    path: '/reporting',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'add',
        component: (resolve) => require(['@/views/patrol/reporting/addReporting'], resolve),
        name: 'AddReporting',
        meta: {title: '新增安全隐患上报'}
      },
      {
        path: 'detail',
        component: (resolve) => require(['@/views/patrol/reporting/reportingDetail'], resolve),
        name: 'ReportingDetail',
        meta: {title: '安全隐患上报详情'}
      }
    ]
  }, {
    path: '/district',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'more',
        component: (resolve) => require(['@/views/patrol/home/district/more.vue'], resolve),
        name: 'more',
        meta: {title: '全部待办'}
      }, {
        path: 'line',
        component: (resolve) => require(['@/views/patrol/line/index.vue'], resolve),
        name: 'line',
        meta: {title: '巡查线路'}
      }, {
        path: 'lineStaff',
        component: (resolve) => require(['@/views/patrol/line_staff/index.vue'], resolve),
        name: 'lineStaff',
        meta: {title: '行政排班'}
      }, {
        path: 'staffLongTerm',
        component: (resolve) => require(['@/views/patrol/line_staff/longTerm.vue'], resolve),
        name: 'staffLongTerm',
        meta: {title: '行政长期'}
      }, {
        path: 'lineGuard',
        component: (resolve) => require(['@/views/patrol/line_guard/index.vue'], resolve),
        name: 'lineGuard',
        meta: {title: '安保排班'}
      }, {
        path: 'guardLongTerm',
        component: (resolve) => require(['@/views/patrol/line_guard/longTerm.vue'], resolve),
        name: 'guardLongTerm',
        meta: {title: '安保长期'}
      }, {
        path: 'staff',
        component: (resolve) => require(['@/views/patrol/site_record_staff/staff.vue'], resolve),
        name: 'staff',
        meta: {title: '检查记录'}
      }, {
        path: 'guard',
        component: (resolve) => require(['@/views/patrol/line_record/guard.vue'], resolve),
        name: 'guard',
        meta: {title: '检查记录'}
      }, {
        path: 'staffCheck',
        component: (resolve) => require(['@/views/patrol/staff/index.vue'], resolve),
        name: 'staffCheck',
        meta: {title: '行政人员'}
      }, {
        path: 'guardCheck',
        component: (resolve) => require(['@/views/patrol/guard/index.vue'], resolve),
        name: 'guardCheck',
        meta: {title: '安保人员'}
      },{
        path: 'daily',
        component: (resolve) => require(['@/views/patrol/form/daily.vue'], resolve),
        name: 'daily',
        meta: {title: '历史表单',noCache: true}
      }
    ]
  }
]

export default new Router({
  mode: 'history', // 去掉url中的#
  scrollBehavior: () => ({y: 0}),
  routes: constantRoutes
})
